<template>
  <div>
    <el-form :model="dataInfo" ref="dataInfo" >
      <div class="detail-info" style="margin-top: 20px">
        <div class="form-item">
          <h4>公告信息</h4>
          <el-form-item label="标题">
            <span>{{dataInfo.title}}</span>
          </el-form-item>
          <el-form-item label="内容">
            <span>{{dataInfo.content}}</span>
          </el-form-item>
          <el-form-item label="ZIP包">
            <el-button type="primary" size="small" @click="downLoad">下载</el-button>           
          </el-form-item>
        </div>
      </div>
    </el-form>
    <div style="margin: 20px auto 20px;width:20%">
      <el-button @click="cancel(menuId)" type="danger">关闭</el-button>
    </div>
  </div>
</template>
<script>
  import { apiHost } from '../../../config/settings.js'
  import { gzt } from '../../../config/proxy.js'
  import mixins from '../../../components/mixins.vue'
  export default {
    mixins: [mixins],
    data () {
      return {
        dataInfo: {
          title: '', // 标题
          content: '', // 内容
          zipUrl: '' // url
        },
        zipError: '', // zip的错误信息
        fileList: [], // 上传文件列表
        zipFlag: false, // 上传的状态
        url: '', // 上传地址
        menuId: '', // 打开的菜单id
        imgHost: ''
      }
    },
    methods: {
      searchDetail (id) { // 查询详情
        gzt.gonggaogl.detail({announceId: id}, res => {
          console.log(res)
          if (res.message === 'ok') {
            this.dataInfo = res.content
          } else {
            this.message(res.message, 'error')
          }
        })
      },
      downLoad () { // 下载
        window.open(this.imgHost + '/' + this.dataInfo.zipUrl)
      },
      cancel (id, num) { // 取消
        if (num) {
          this.$confirm('确定要取消？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$store.dispatch('delTab', {id: id})
          }).catch(() => {
          })
        } else {
          this.$store.dispatch('delTab', {id: id})
        }
      },
      message (text, type) { // 消息提示
        this.$message({
          showClose: true,
          message: text,
          type: type
        })
      }
    },
    computed: {
      update_state: function () {
        // console.log(state.updateState.dhmState)
        return this.$store.state.updateState.pttcState
      },
      userName: function () {
        if (!this.$store.state.user.info.user_name) {
          this.$store.dispatch('SET_TOKEN')
        }
        return this.$store.state.user.info.user_name
      },
      userId: function () {
        return this.$store.state.user.info.user_id
      },
      roleId: function () {
        return this.$store.state.user.info.roleid
      },
      branchName: function () {
        return this.$store.state.user.info.branchId === 1 ? '总公司' : this.$store.state.user.info.branchName
      },
      branchId: function () {
        return this.$store.state.user.info.branchId
      },
      deptName: function () {
        return this.$store.state.user.info.parOrgName
      },
      deptId: function () {
        return this.$store.state.user.info.or_org_id
      },
      branchOrgId: function () {
        return this.$store.state.user.info.branchOrgId
      },
      uorId: function () {
        return this.$store.state.user.info.uor_id
      },
      user_telphone: function () {
        return this.$store.state.user.info.user_telphone
      }
    },
    created () {
      this.menuId = this.$store.state.tab.menuId
      this.imgHost = apiHost.imgHost
      this.searchDetail(this.$store.state.tab.uid)
    }
  }
</script>
